/*
https://leetcode.cn/problems/count-and-say/
*/
class Solution {
public:
    string countAndSay(int n) {
    string res="1";
        res="1";
        n-=1;
    string ress="";
    for(int i=0;i<n;++i)
    {
        int count=0;
        char last=res[0];
        ress=res;
        string qq="";
        //cout<<"当前答案："<<res<<endl;
        for(int p=0;p<res.size();++p){
            if(last==ress[p]){
                count++;
            }
            if(last!=ress[p]){
                qq=qq+to_string(count)+last;
                last=ress[p];
             
                count=1;
            }
            if(p+1==ress.size()){
                qq=qq+to_string(count)+last;
            }
        }
        res=qq;
    }
    return res;
    }
};